home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1382 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: alt.msdos.programmer,comp.lang.c
  4. Subject: Re: Some C problems
  5. Date: 13 Jan 1996 07:06:08 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Jan13000608@qcd.lanl.gov>
  8. References: <4d0fjj$eok@lugb.latrobe.edu.au> <4d4pg7$3ot@news.dx.net>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: robmc@shol.com's message of 12 Jan 1996 04:53:27 GMT
  13.  
  14. --text follows this line--
  15. In article <4d4pg7$3ot@news.dx.net> robmc@shol.com (Rob McCafferty) writes:
  16. <snip>
  17.    I believe C assumes numeric constants are signed.  Try using 65535U.
  18.  
  19. Unsuffixed decimal constants are signed unless a long is insufficient
  20. to hold them, in which case they are unsigned. (If they don't fit into
  21. an unsigned long, it is an error).
  22.  
  23. For octal and hexadecimal, they are signed; except if they fit into an
  24. unsigned int or unsigned long, but not into the corresponding signed
  25. type. 
  26.  
  27. <snip>
  28.    >How do you use literal constants bigger than words e.g. how would you use
  29.    >the literal constant 1000000 without getting the 'constant out of range'
  30.    >warning/error?
  31.  
  32.    Again, C assumes constants are int unless you tell it otherwise.  Make this
  33.    1000000L.
  34.  
  35. An ANSI C compiler has to interpret 1000000 and 1000000L identically
  36. if 1000000 > MAX_INT (because it must fit into an unsigned int, there
  37. is no possibility of it being an error).
  38.  
  39. ANSI C compilers assume unsufixed constants to be ints, _unless_ they
  40. do not fit into an int. In this case, long and unsigned long are
  41. tried. For octal and hexadecimal constants, unsigned int is tried
  42. before trying signed and unsigned longs.
  43.  
  44. Cheers
  45. Tanmoy
  46. --
  47. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  48. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  49. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  50. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  51. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  52. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  53.